﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>萤火虫动画</title>

    <style>
        body {
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            height: 100vh;
            background: radial-gradient(#0a2a43 30%, #09243a);
            font-family: 'Asap', sans-serif;
        }

            body:after {
                content: '';
                display: block;
                position: absolute;
                top: 1rem;
                right: 1rem;
                bottom: 1rem;
                left: 1rem;
                border: 4px solid #071c2d;
                border-radius: 2px;
                background: none;
                pointer-events: none;
            }

        .label {
            flex: 0;
            color: #b8c5d0;
            letter-spacing: .04em;
            text-align: center;
            margin-bottom: 2rem;
            font-size: 3rem;
        }

        @media screen and (min-width: 60rem) {
            .label {
                font-size: 5vw;
            }
        }

        .checkbox-wrap {
            flex: none;
            position: relative;
            width: 10%;
            min-width: 8rem;
            z-index: 1;
        }

            .checkbox-wrap:after {
                content: '';
                display: block;
                padding-top: 50%;
            }

        .checkbox {
            display: none;
        }

            .checkbox:checked ~ .firefly .fire_fly_abdomen {
                background: #27231e;
                box-shadow: inset 0 0 1.5rem rgba(150, 0, 0, 0.75);
                animation: flicker 4000ms ease infinite;
            }

            .checkbox:checked ~ .firefly .wing-up {
                transform: rotate(30deg);
            }

            .checkbox:checked ~ .firefly .wing-blow {
                transform: rotate(-30deg);
            }

        .fire_fly_head {
            position: absolute;
            top: 15%;
            left: 60%;
            bottom: 15%;
            background: #27231e;
            width: 70%;
            border-radius: 40% 80% 80% 40%;
            box-shadow: inset -0.1rem 0 0 0.3rem rgba(14, 10, 10, 0.2);
        }

        .fire_fly_eyes {
            position: absolute;
            top: -5%;
            right: 10%;
            bottom: -5%;
            width: 35%;
        }

            .fire_fly_eyes:before, .fire_fly_eyes:after {
                content: '';
                display: block;
                position: absolute;
                right: 0;
                width: 100%;
                box-sizing: border-box;
                border-radius: 100%;
                background: #0e0a0a;
                padding-top: 100%;
            }

            .fire_fly_eyes:before {
                top: 0;
            }

            .fire_fly_eyes:after {
                bottom: 0;
            }

        .fire_fly_antennae {
            position: absolute;
            top: 20%;
            left: -150%;
            bottom: 20%;
            width: 400%;
            z-index: -1;
        }

            .fire_fly_antennae:before, .fire_fly_antennae:after {
                content: '';
                display: block;
                position: absolute;
                right: 0;
                width: 100%;
                box-sizing: border-box;
                border-color: #0e0a0a;
                border-style: solid;
                padding-top: 65%;
                border-width: .25rem .25rem .25rem 0;
            }

            .fire_fly_antennae:before {
                top: 80%;
                border-radius: 0 100% 100% 100%;
            }

            .fire_fly_antennae:after {
                bottom: 80%;
                border-radius: 100% 100% 100% 0;
            }

        .fire_fly_thorax {
            position: absolute;
            top: 0;
            left: 100%;
            bottom: 0;
            background: #d43b1f;
            width: 30%;
            border-radius: 20% 80% 80% 20%;
            box-shadow: inset -0.1rem 0 0.1rem 0.3rem rgba(0, 0, 0, 0.2);
        }

        .fire_fly_abdomen {
            position: absolute;
            top: 10%;
            right: 20%;
            bottom: 10%;
            background: #27231e;
            width: 100%;
            transition: all 1000ms ease;
            border-radius: 100% 30% 30% 100%;
            box-sizing: border-box;
        }

            .fire_fly_abdomen:after {
                content: '';
                display: block;
                position: absolute;
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
                background: repeating-linear-gradient(90deg, transparent 0, transparent 15%, rgba(0, 0, 20, 0.1) 15%, rgba(0, 0, 20, 0.1) 20%);
                mix-blend-mode: multiply;
                border-radius: 100% 30% 30% 100%;
                z-index: 0;
                box-shadow: inset -1rem 0 0.2rem 0.3rem rgba(0, 0, 0, 0.1);
            }

        .fire_fly_wings {
            position: absolute;
            top: -20%;
            right: 0;
            bottom: -20%;
            left: -5%;
            z-index: 1;
        }

            .fire_fly_wings .wing {
                position: absolute;
                right: 0;
                background: repeating-linear-gradient(#27231e 0%, #27231e 40%, #191613 40%, #191613 60%);
                width: 100%;
                height: 50%;
                transition: all 200ms ease-out;
                border: 1px solid #40341d;
                box-sizing: border-box;
                box-shadow: inset 0.2rem 0 0.1rem 0.5rem rgba(0, 0, 0, 0.5);
            }

                .fire_fly_wings .wing.wing-up {
                    transform-origin: bottom right;
                    top: 0;
                    border-radius: 90% 30% 0 20%;
                }

                .fire_fly_wings .wing.wing-blow {
                    transform-origin: top right;
                    top: 50%;
                    border-radius: 20% 0 30% 90%;
                }

        @keyframes flicker {
            0%, 100% {
                background: #fefa01;
                box-shadow: 0 0 1rem #fefa01, inset -0.25rem 0 0 0.5rem rgba(14, 10, 10, 0.1);
            }

            30%, 70% {
                background: #fffd99;
                box-shadow: -1rem 0 8rem 1rem #fefa01, inset -0.25rem 0 0 0.5rem rgba(14, 10, 10, 0.1);
            }

            50% {
                box-shadow: -1rem 0 8rem 1rem rgba(254, 250, 1, 0.8), inset -0.25rem 0 0 0.5rem rgba(14, 10, 10, 0.1);
            }
        }
    </style>

</head>
<body>

    <div class="checkbox-wrap">
        <input class="checkbox" id="checkbox" type="checkbox" />
        <label class="firefly" for="checkbox">
            <!-- 萤火虫腹部 -->
            <div class="fire_fly_abdomen">
                <!-- 胸膛 -->
                <div class="fire_fly_thorax">
                    <!-- 头部 -->
                    <div class="fire_fly_head">
                        <!-- 眼睛 -->
                        <div class="fire_fly_eyes"></div>

                        <!-- 触角 -->
                        <div class="fire_fly_antennae"></div>
                    </div>
                </div>
                <!-- 萤火虫翅膀 -->
                <div class="fire_fly_wings">
                    <div class="wing wing-up"></div>
                    <div class="wing wing-blow"></div>
                </div>
            </div>
        </label>

    </div>

</body>
</html>